import Vue from 'vue'

import App from './App'
// import router from '../main'
import store from '../../store'
import MyStorage from '../../plugins/MyStorage'

Vue.use(MyStorage)

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.config.productionTip = false

// window.addEventListener('storage', (ev) => {
//   if (ev.key !== 'communication') return
//   let arg = myStorage.getItem('communication', {})
//   switch (arg.action) {
//     case 'addSession':
//       Vue.prototype.$electron.remote.getCurrentWindow().focus()
//       store.dispatch('addSession', arg.data)
//       break
//     case 'addMsg':
//       store.dispatch('addMsg', arg.data)
//       break
//   }
// })

Vue.prototype.$electron.ipcRenderer.on('clearSession', () => {
  store.dispatch('clearSessionList')
})
/* eslint-disable no-new */
new Vue({
  components: {App},
  // router,
  store,
  template: '<App/>'
}).$mount('#app')
